#ifndef WYTIMER_H
#define WYTIMER_H

#include "stdfax.h"
#include "timeval.h"
#include "rbtree.h"

typedef void (timercb)(void *);

typedef struct _tnode {
	struct timeval expired_time;
	long offset;
	int repeat;
	void * param;
	timercb* cb;
}tnode;


typedef struct _rbtimer {
	
	rbtree* timer_queue;
}rbtimer;

inline rbtimer* get_timer();
int rbt_comp_ttl_gt(void *v1, void *v2, void *argv);

void update_time();

void timer_add(int sec, int msec, timercb cb, void * param,int repeat);

void timer_cycle_add(int sec, int msec, struct timeval cirtv, timercb cb, void * param, int repeat);


void* do_timer(void*);

#endif